import { get_college } from "@/api/college";
import { defineStore } from "pinia";
import type { FormConfig } from "@components/FormComponent/types";
import { ref } from "vue";

export const useCollege = defineStore("college", () => {
    const FormCon = ref<FormConfig[]>([
        {
            key: "college",
            label: "学院",
            comType: "el-select",
            placeholder: "请选择学院",
            options: [
                {
                    label: "无",
                    value: ""
                }
            ],
        },
        {
            key: "major",
            label: "专业",
            comType: "el-select",
            placeholder: "请选择专业",
            options: [],
        },
        {
            key: "grade",
            label: "年级",
            comType: "el-select",
            placeholder: "请选择年级",
            options: [
                {
                    label: "无",
                    value: ""
                },
                {
                    label: "2019",
                    value: "2019"
                },
                {
                    label: "2020",
                    value: "2020"
                },
                {
                    label: "2021",
                    value: "2021"
                }
            ],
        },
        {
            key: "keyword",
            label: "帖子查询",
            comType: "el-input",
            placeholder: "请输入关键字",
        },
    ]);
    (async () => {
        const res = await get_college();
        if (res.code === 200) {
            res.data.forEach((item) => {
                FormCon.value[0].options.push({
                    value: item,
                    label: item
                })
            })
        }
    })()
    return { FormCon }
})